package com.ruoyi.web.controller.monitorTools;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.monitorTools.domain.HotSpotRegion;
import com.ruoyi.monitorTools.service.HotSpotRegionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description TODO
 * @Author wsl
 * @Date 2025-02-17 13:38
 * @Version 1.0
 */

@RestController
@RequestMapping("/hotSpot/region")
@Api(tags = "热点区域")
public class HotSpotRegionController extends BaseController {

    @Autowired
    private HotSpotRegionService hotSpotRegionService;


    @PostMapping
    @ApiOperation("热点区域-add")
    public AjaxResult add(@RequestBody HotSpotRegion hotSpotRegion){
        return toAjax(hotSpotRegionService.insertOne(hotSpotRegion));
    }

    @DeleteMapping
    @ApiOperation("热点区域-删除")
    public AjaxResult delete(@RequestParam("idList") ArrayList<Integer> idList){
        return toAjax(hotSpotRegionService.removeByIds(idList));
    }

    @PutMapping
    @ApiOperation("热点区域-update")
    public AjaxResult update(@RequestBody HotSpotRegion hotSpotRegion) {
        return toAjax(hotSpotRegionService.updateById(hotSpotRegion));
    }

    @GetMapping
    @ApiOperation("热点区域-selectById")
    public AjaxResult selectById(Long id){
        return AjaxResult.success(hotSpotRegionService.selectHotById(id));
    }

    @GetMapping("listByPage")
    @ApiOperation("热点区域-分页查询")
    public TableDataInfo list(String regionName, Integer enableStatus){
        startPage();
        List<HotSpotRegion> list = hotSpotRegionService.listByPage(regionName, enableStatus);
        return getDataTable(list);
    }

    @GetMapping("selectOtherList")
    @ApiOperation("热点区域-查询其他区域")
    public AjaxResult selectOtherList(){
        return AjaxResult.success(hotSpotRegionService.selectOtherList());
    }


    @PostMapping("batchUpdateEnableStatus")
    @ApiOperation("热点区域-批量修改状态")
    public AjaxResult batchUpdateEnableStatus(@RequestParam("idList") ArrayList<Integer> idList, @RequestParam("enableStatus") Integer enableStatus){
        return hotSpotRegionService.batchUpdateEnableStatus(idList, enableStatus);
    }

    @GetMapping("getTargetSize")
    @ApiOperation("热点区域-获取热力数据")
    public AjaxResult getTargetSizeByRegion(){
        return AjaxResult.success(hotSpotRegionService.getTargetSizeByRegion());
    }




}
